﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                        <div class="col-sm-12">
                           <div class="form-group from-inline">
                                <label class="col-sm-3 control-label" for="name">身份确认:</label>
                                <div class="col-sm-4">
							      <input id="phone" type="text" placeholder="请输入手机号码" class="input-sm form-control">
							      </div>
							     <div class="col-sm-4" style="text-align: center;margin-top: 10px;">
							      <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 查询</a>
							    </div>
                          </div>
                        </div>
                    </div>
                </div>
                <!-- biaogebigin -->
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;display: none;" id="content">
                    <form class="form-horizontal m-t form-inline" id="signupForm" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="id" id="id"/>
                        <input type="hidden" name="companyId" id="companyId" value="${companyId }"/>
						<div class="form-group">
							<label class="col-sm-2 control-label">姓名：</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="trueName" name="trueName"/>
							</div>
							<label class="col-sm-2 control-label">联系电话：</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="cellphone" name="cellphone" />
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">微信：</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="wechat" name="wechat" />
							</div>
							<label class="col-sm-2 control-label">QQ：</label>
							<div class="col-sm-4 form-inline">
								<input type="text" class="form-control" id="qq" name="qq" />
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">邮箱：</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="email" name="email" onblur="isEmail('email',this.value)"/>
							</div>
							<label class="col-sm-2 control-label">公司职位：</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="position" name="position"/>
							</div>
						</div>
						<div class="form-group" style="text-align: center;">
							<div class="col-sm-8 col-sm-offset-3">
								<button class="btn btn-primary" type="button" id="sub">提交</button>
							</div>
						</div>
					</form>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    $(function(){
    	$("#find_btn").click(function () {
    		var phone = $("#phone").val();
    		if(phone!=""){
    			 $.ajax({
       			  url: '<%=contextPath%>/resume/getByPhone',
          		      data:{phone:phone},
      				  type : 'post',
      				  dataType : "json",
      				  success : function(data) {
      					if (data.code == 200) {
      						$("#id").val(data.resumes.id);
      						$("#trueName").val(data.resumes.trueName);
      						$("#cellphone").val(data.resumes.cellphone);
      						$("#wechat").val(data.resumes.wechat);
      						$("#qq").val(data.resumes.qq);
      						$("#email").val(data.resumes.email);
      						$("#position").val(data.resumes.position);
      						swal({ 
        						  title: "查询成功,请继续操作", 
        						  text: "1秒后自动关闭。", 
        						  timer: 1000, 
        						  showConfirmButton: false 
        						});
      					}else {
      						swal({ 
      						  title: "查询成功,暂无数据", 
      						  text: "1秒后自动关闭。", 
      						  timer: 1000, 
      						  showConfirmButton: false 
      						});
						}
      					$("#content").show();
      				}
       		   });
    		}else {
    			swal({ 
					  title: "请输入手机号码", 
					  text: "1秒后自动关闭。", 
					  timer: 1000, 
					  showConfirmButton: false 
					});
			}
    	});
    	$("#sub").click(function () {
        	//调用方式
        	var arr=new Array(
        	  new Array('trueName','姓名未填写!'),
        	  new Array('cellphone','手机号码未填写!'),
        	  new Array('wechat','微信未填写!'),
        	  new Array('qq','QQ未填写!'),
        	  new Array('email','邮箱未填写!'),
        	  new Array('postion','公司职位未填写!')
        	);
        	//批量验证表单非空
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  };
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/company/addContact',
					type : 'post',
					dataType : "json",
					beforeSend: function () {
				        // 禁用按钮防止重复提交
						$("#sub").attr("disabled","disabled");
						swal("信息已经提交，请等待后台处理~！");
				    },
					success : function(data) {
						if (data.code == 200) {
							swal({
								title : data.message,
								type : "success",
								showCancelButton : false,
								confirmButtonText : "确定",
								animation : "slide-from-bottom",
								closeOnConfirm : true
							}, function() {
								top.Dialog.close();
							});
						} else {
							swal("错误", data.message, "error");
						}
					},
					complete: function () {
				        $("#sub").removeAttr("disabled");
				    },
				    error: function (data) {
				    	swal("错误", data.message, "error");
				    }
				});

			});
    })
</script>
</body>
</html>

